#include "DescriptionTab.h"
#include "ConceptTab.h"

#pragma once

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Xml;


namespace lcabinet {

	/// <summary>
	/// Summary for CharacterTab
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class CharacterTab : public System::Windows::Forms::Form
	{
	public:
		CharacterTab(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
			initializePanel();
			lstNavigation->SetSelected(0, true);
			setCurrentPanelDisplay(0);
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~CharacterTab()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::ListBox^  lstNavigation;
	private: System::Windows::Forms::Panel^  pnlDataArea;
	protected: 


	protected: 
		Form^ m_cCurrentPanelDisplay;
		DescriptionTab^ m_cDescriptionTab;
		ConceptTab^ m_cConceptTab;
		XmlNode^ m_pcTypeNode;
		XmlNode^ m_pcTemplateNode;

	protected: 



	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->lstNavigation = (gcnew System::Windows::Forms::ListBox());
			this->pnlDataArea = (gcnew System::Windows::Forms::Panel());
			this->SuspendLayout();
			// 
			// lstNavigation
			// 
			this->lstNavigation->BackColor = System::Drawing::SystemColors::Control;
			this->lstNavigation->BorderStyle = System::Windows::Forms::BorderStyle::None;
			this->lstNavigation->FormattingEnabled = true;
			this->lstNavigation->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"Description", L"Concept", L"Attributes", 
				L"Abilities"});
			this->lstNavigation->Location = System::Drawing::Point(12, 12);
			this->lstNavigation->Name = L"lstNavigation";
			this->lstNavigation->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
			this->lstNavigation->Size = System::Drawing::Size(120, 91);
			this->lstNavigation->TabIndex = 0;
			this->lstNavigation->SelectedIndexChanged += gcnew System::EventHandler(this, &CharacterTab::lstNavigation_SelectionChange);
			// 
			// pnlDataArea
			// 
			this->pnlDataArea->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
			this->pnlDataArea->Location = System::Drawing::Point(139, 12);
			this->pnlDataArea->Name = L"pnlDataArea";
			this->pnlDataArea->Size = System::Drawing::Size(539, 494);
			this->pnlDataArea->TabIndex = 1;
			// 
			// CharacterTab
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(690, 518);
			this->ControlBox = false;
			this->Controls->Add(this->pnlDataArea);
			this->Controls->Add(this->lstNavigation);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::None;
			this->MaximizeBox = false;
			this->MinimizeBox = false;
			this->Name = L"CharacterTab";
			this->ShowIcon = false;
			this->ShowInTaskbar = false;
			this->Text = L"CharacterTab";
			this->ResumeLayout(false);

		}
#pragma endregion
		System::Void lstNavigation_SelectionChange(System::Object^  sender, System::EventArgs^  e) 
		{
			String^ strSelectedItem = lstNavigation->SelectedItem->ToString();
			int nIndex = lstNavigation->FindString(strSelectedItem);

			setCurrentPanelDisplay(nIndex);
		}

		System::Void setCurrentPanelDisplay(int nDisplayIndex)
		{
			switch (nDisplayIndex)
			{
			case 0:
			default:
				{
					if (m_cCurrentPanelDisplay)
					{
						m_cCurrentPanelDisplay->Hide();
					}
					m_cDescriptionTab->Show();
					m_cCurrentPanelDisplay = m_cDescriptionTab;
					break;
				}
			case 1:
				{
					if (m_cCurrentPanelDisplay)
					{
						m_cCurrentPanelDisplay->Hide();
					}
					m_cConceptTab->Show();
					m_cCurrentPanelDisplay = m_cConceptTab;
					break;
				}
			}
			Invalidate();
		}

		System::Void initializePanel()
		{
			m_cDescriptionTab = gcnew DescriptionTab();
			m_cConceptTab = gcnew ConceptTab();

			m_cDescriptionTab->TopLevel = false;
			m_cDescriptionTab->Parent = pnlDataArea;
			m_cDescriptionTab->Dock = DockStyle::Fill;
			pnlDataArea->Controls->Add(m_cDescriptionTab);
			m_cDescriptionTab->Hide();

			m_cConceptTab->TopLevel = false;
			m_cConceptTab->Parent = pnlDataArea;
			m_cConceptTab->Dock = DockStyle::Fill;
			pnlDataArea->Controls->Add(m_cConceptTab);
			m_cConceptTab->Hide();
		}
	public:

		System::Void SetTypeNode(XmlNode^ pcType)
		{
			m_pcTypeNode = pcType;
		}

		System::Void SetTemplateNode(XmlNode^ pcTemplate)
		{
			m_pcTemplateNode = pcTemplate;
		}

	};
}
